package com.qingxin.sys.tag;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 定义EL表达式函数
 * @author Administrator
 *
 */
public class ELFunctions {

	/**
	 * 格式化输出日期对象
	 * @param date
	 * @param pattern
	 * @return
	 */
	public static String fmt(Date date, String pattern){
		if (date == null) {
			return "";
		}
		try {
			return (new SimpleDateFormat(pattern)).format(date);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
	
	
	/**
	 * 当两个参数字面量相等时输出checked="checked"
	 * @param value
	 * @param target
	 * @return
	 */
	public static String chk(Object value, Object target){
		if(value == null || target==null){
			return "";
		}
		if(value.toString().equals(target.toString())){
			return "checked=\"checked\"";
		}
		return "";
	}
	
	
}
